//===============================================
//  head file for pmic da9030
//  author: zhenguo
//  08-07-05
//===============================================

#ifndef __PMIC_DA9030_H
#define __PMIC_DA9030_H

#define PMIC_DA9030_ADDR 0x92


#define PMIC_ID_REG                    0x00 //Read Only,  SYSMON
#define PMIC_EVENT_A_REG            0x01 //Read Only,  SYSMON
#define PMIC_EVENT_B_REG            0x02 //Read Only,  SYSMON
#define PMIC_EVENT_C_REG            0x03 //Read Only,  SYSMON
#define PMIC_STATUS_REG                0x04 //Read Only,  SYSMON
#define PMIC_IRQ_MASK_A_REG            0x05 //Read-Write, SYSMON
#define PMIC_IRQ_MASK_B_REG            0x06 //Read-Write, SYSMON
#define PMIC_IRQ_MASK_C_REG            0x07 //Read-Write, SYSMON
#define PMIC_SYS_CTRL_A_REG            0x08 //Read-Write, SYSMON
#define PMIC_SYS_CTRL_B_REG            0x09 //Read-Write, SYSMON
#define PMIC_FAULT_LOG_B_REG        0x0A //Read-Write, SYSMON

#define PMIC_LDO_10_11_REG            0x10 //Read-Write, SYSMON
#define PMIC_LDO_15_REG                0x11 //Read-Write, SYSMON
#define PMIC_LDO_14_16_REG            0x12 //Read-Write, SYSMON
#define PMIC_LDO_18_19_REG            0x13 //Read-Write, SYSMON
#define PMIC_LDO_17_SIMCP0_REG        0x14 //Read-Write, SYSMON
#define PMIC_BUCK2_DVC1_REG            0x15 //Read-Write, SYSMON
#define PMIC_BUCK2_DVC2_REG            0x16 //Read-Write, SYSMON
#define PMIC_CTRL1_REG                0x17 //Read-Write, SYSMON
#define PMIC_CTRL2_REG                0x18 //Read-Write, SYSMON
#define PMIC_USB_PUMP_REG            0x19 //Read-Write, SYSMON
#define PMIC_APP_SLEEP_CTRL_REG        0x1A //Read-Write, SYSMON
#define PMIC_STARTUP_CTRL_REG        0x1B //Read-Write, SYSMON

#define PMIC_LED1_CTRL_REG            0x20 //Read-Write, SYSMON
#define PMIC_LED2_CTRL_REG            0x21 //Read-Write, SYSMON
#define PMIC_LED3_CTRL_REG            0x22 //Read-Write, SYSMON
#define PMIC_LED4_CTRL_REG            0x23 //Read-Write, SYSMON
#define PMIC_LEDPC_CTRL_REG            0x24 //Read-Write, SYSMON
#define PMIC_WLED_CP_CTRL_REG        0x25 //Read-Write, SYSMON
#define PMIC_MISC_A_REG                0x26 //Read-Write, SYSMON
#define PMIC_MISC_B_REG                0x27 //Read-Write, SYSMON
#define PMIC_CHARGER_CTRL_REG        0x28 //Read-Write, SYSMON
#define PMIC_CHARGER_CCTR_REG        0x29 //Read-Write, SYSMON
#define PMIC_CHARGER_TCTR_REG        0x2A //Read-Write, SYSMON
#define PMIC_CHARGER_PULSE_REG        0x2B //Read-Write, SYSMON

#define PMIC_ADC_MAN_CTRL_REG        0x30 //Read-Write, SYSMON
#define PMIC_ADC_AUTO_CTRL1_REG        0x31 //Read-Write, SYSMON
#define PMIC_VBATMON_REG            0x32 //Read-Write, SYSMON
#define PMIC_VBATMON_TXON_REG          0x33 //Read-Write, SYSMON
#define PMIC_TBAT_HIGHP_REG            0x34 //Read-Write, SYSMON
#define PMIC_TBAT_HIGHN_REG            0x35 //Read-Write, SYSMON
#define PMIC_TBAT_LOW_REG            0x36 //Read-Write, SYSMON

#define PMIC_MAN_RES_REG            0x40 //Read-Write, SYSMON
#define PMIC_VBAT_RES_REG            0x41 //Read-Write, SYSMON
#define PMIC_VBAT_MIN_RES_REG        0x42 //Read-Write, SYSMON
#define PMIC_VBAT_MIN_TXON_REG      0x43 //Read-Write, SYSMON
#define PMIC_ICHMAX_RES_REG            0x44 //Read-Write, SYSMON
#define PMIC_ICHMIN_RES_REG            0x45 //Read-Write, SYSMON
#define PMIC_ICHAVRG_RES_REG        0x46 //Read-Write, SYSMON
#define PMIC_VCHMAX_RES_REG            0x47 //Read-Write, SYSMON
#define PMIC_VCHMIN_RES_REG            0x48 //Read-Write, SYSMON
#define PMIC_TBAT_REG                0x49 //Read-Write, SYSMON
#define PMIC_ADC_IN4_RES_REG          0x4A //Read-Write, SYSMON

#define PMIC_SPAMP_CTRL1_REG        0x50 //Read-Write, SYSMON
#define PMIC_SPAMP_CTRL2_REG        0x51 //Read-Write, SYSMON

#define PMIC_SYS_CTRL_C_REG            0x80 //Read-Write, SYSMON
#define PMIC_FAULT_LOG_C_REG        0x81 //Read-Write, SYSMON

#define PMIC_LDO_1_REG                0x90 //Read-Write, SYSMON
#define PMIC_LDO_2_3_REG            0x91 //Read-Write, SYSMON
#define PMIC_LDO_4_5_REG            0x92 //Read-Write, SYSMON
#define PMIC_LDO_6_SIMCP_REG        0x93 //Read-Write, SYSMON
#define PMIC_LDO_7_8_REG            0x94 //Read-Write, SYSMON
#define PMIC_LDO_9_12_REG            0x95 //Read-Write, SYSMON
#define PMIC_BUCK_CTRL_REG            0x96 //Read-Write, SYSMON
#define PMIC_REG_CTRL1_REG            0x97 //Read-Write, SYSMON
#define PMIC_REG_CTRL2_REG          0x98 //Read-Write, SYSMON
#define PMIC_REG_SLEEP_CTRL1_REG     0x99 //Read-Write, SYSMON
#define PMIC_REG_SLEEP_CTRL2_REG     0x9A //Read-Write, SYSMON
#define PMIC_REG_SLEEP_CTRL3_REG     0x9B //Read-Write, SYSMON

#define DA9030_IRQ(x)            x

// in EVENT_A
#define DA9030_ONKEY_IRQ            DA9030_IRQ(0)
#define DA9030_PWEN1_IRQ            DA9030_IRQ(1)
#define DA9030_EXTON_IRQ            DA9030_IRQ(2)
#define DA9030_CHDET_IRQ            DA9030_IRQ(3)
#define DA9030_TBAT_IRQ                DA9030_IRQ(4)
#define DA9030_VBATMON_IRQ             DA9030_IRQ(5)
#define DA9030_VBATMONTXON_IRQ        DA9030_IRQ(6)
#define DA9030_CHIOVER_IRQ            DA9030_IRQ(7)

// in EVENT_B
#define DA9030_TCTO_IRQ            DA9030_IRQ(8)
#define DA9030_CCTO_IRQ            DA9030_IRQ(9)
#define DA9030_ADCREADY_IRQ        DA9030_IRQ(10)
#define DA9030_VBUS4P4_IRQ        DA9030_IRQ(11)
#define DA9030_VBUS4P0_IRQ        DA9030_IRQ(12)
#define DA9030_SESSION_IRQ      DA9030_IRQ(13)
#define DA9030_SRPDET_IRQ        DA9030_IRQ(14)
#define DA9030_WHDOG_IRQ        DA9030_IRQ(15)

// in  EVENT_C
#define DA9030_LDO15_IRQ        DA9030_IRQ(16)
#define DA9030_LDO16_IRQ        DA9030_IRQ(17)
#define DA9030_LDO17_IRQ        DA9030_IRQ(18)
#define DA9030_LDO18_IRQ        DA9030_IRQ(19)
#define DA9030_LDO19_IRQ        DA9030_IRQ(20)
#define DA9030_BUCK2_IRQ        DA9030_IRQ(21)
#define DA9030_ADCIN4_IRQ        DA9030_IRQ(22)
#define DA9030_ADCIN5_IRQ        DA9030_IRQ(23)

//EVENT_A bit defination
#define ONKEY_IRQ          (1 << 0)
#define PWEN1_IRQ          (1 << 1)
#define EXTON_IRQ          (1 << 2)
#define CHDET_IRQ          (1 << 3)
#define TBAT_IRQ          (1 << 4)
#define VBATMON_IRQ       (1 << 5)
#define VBATMONTXON_IRQ      (1 << 6)
#define CHIOVER_IRQ          (1 << 7)

//status bit defination
#define ONKEY_STATUS          (1 << 0)
#define PWEN1_STATUS          (1 << 1)
#define EXTON_STATUS          (1 << 2)
#define CHDET_STATUS          (1 << 3)
#define TBAT_STATUS              (1 << 4)
#define VBATMON_STATUS           (1 << 5)
#define VBATMONTXON_STATUS      (1 << 6)
#define CHIOVER_STATUS          (1 << 7)

//Battery Charge Mode
#define MODE_QUALIFICATION   0x00// qualification mode
#define MODE_PRECHARGE       0x01// pre charge mode
#define MODE_TRICKLE         0x02// trickle charge mode
#define MODE_FASTCCCV        0x03// fast charge mode (CCCV)
#define MODE_FASTNOCC        0x04// fast charge mode (no CC)
#define MODE_FASTNOCV        0x05// fast charge mode (no CV)
#define MODE_SWITCH          0x06// switch mode (no CC, no CV)
#define MODE_IDLE            0x07// idle mode

//Battery Charge Current
#define CHARGE_40mA          0x84
#define CHARGE_100mA         0x94
#define CHARGE_200mA         0x9C
#define CHARGE_300mA         0xA4
#define CHARGE_400mA         0xAC
#define CHARGE_500mA         0xB4
#define CHARGE_600mA         0xBC
#define CHARGE_700mA         0xC4
#define CHARGE_800mA         0xCC
#define CHARGE_900mA         0xD4
#define CHARGE_1000mA        0xDC
#define CHARGE_1100mA        0xE4
#define CHARGE_1200mA        0xEC
#define CHARGE_1300mA        0xF4
#define CHARGE_1400mA        0xFC

//Battery Threshold voltage
#define BTV_000 0x0    //n.a.
#define BTV_280 0x1    //2.80 V
#define BTV_290 0x2    //2.90 V
#define BTV_300 0x3    //3.00V
#define BTV_310 0x4    //3.10 V
#define BTV_320 0x5    //3.20 V
#define BTV_330 0x6    //3.30 V
#define BTV_340 0x7    //3.40 V

//Battery Charge Control Voltage
#define CHV_400 0x00 //4.00 V
#define CHV_402 0x01 //4.02 V
#define CHV_404 0x02 //4.04 V
#define CHV_406 0x03 //4.06 V
#define CHV_408 0x04 //4.08 V
#define CHV_410 0x05 //4.10 V
#define CHV_412 0x06 //4.12 V
#define CHV_414 0x07 //4.14 V
#define CHV_416 0x08 //4.16 V
#define CHV_418 0x09 //4.18 V
#define CHV_420 0x0A //4.20 V
#define CHV_422 0x0B //4.22 V
#define CHV_424 0x0C //4.24 V
#define CHV_426 0x0D //4.26 V
#define CHV_428 0x0E //4.28 V
#define CHV_500 0x0F //5.00 V

//Charge Interrupt Register Bit
#define CHGINS_INT      0x01
#define CHGRM_INT       0x02
#define CHGFOK_INT      0x04
#define CHGERR_INT      0x08
#define CHGFRDY_INT     0x10
#define CHGPROT_INT     0x20
#define CHGWD10S_INT    0x40
#define CHGWDEXP_INT    0x80

#define LOWBAT_INT      0x40
#define HIGHTMP_INT     0x80

#endif
